package lab9hw;

public class Computer {

	private int year;
	private double price;
	private boolean isNotebook;
	private long hardDiskMemory;
	private long freeMemory;
	private String operationSystem;
	
	public Computer() {
		super();
		isNotebook = false;
		operationSystem = "Win XP";
	}

	public Computer(int year, double price, long hardDiskMemory, long freeMemory) {
		this();
		this.year = year;
		this.price = price;
		this.hardDiskMemory = hardDiskMemory;
		this.freeMemory = freeMemory;
	}

	public Computer(int year, double price, boolean isNotebook,
			long hardDiskMemory, long freeMemory, String operationSystem) {
		this(year, price, hardDiskMemory, freeMemory);
		this.isNotebook = isNotebook;
		this.operationSystem = operationSystem;
	}
	

	public int getYear() {
		return year;
	}

	public double getPrice() {
		return price;
	}

	public boolean isNotebook() {
		return isNotebook;
	}

	public long getHardDiskMemory() {
		return hardDiskMemory;
	}

	public long getFreeMemory() {
		return freeMemory;
	}

	public String getOperationSystem() {
		return operationSystem;
	}

	@Override
	public String toString() {
		return "Computer [year=" + year + ", price=" + price + ", isNotebook="
				+ isNotebook + ", hardDiskMemory=" + hardDiskMemory
				+ ", freeMemory=" + freeMemory + ", operationSystem="
				+ operationSystem + "]";
	}

	public void changeOperationSystem(String newOperationSystem) {
		operationSystem = newOperationSystem;
	}

	public void useMemmory(double memory) {
		if (freeMemory >= memory) {
			freeMemory -= memory;
		} else
			System.out.println("Not enough free memory!");
	}
	
	public int comparePrice(Computer c) {
		if (c.getPrice()>this.price) return 1;
		else if (c.getPrice()==this.price) return 0;
		else return -1;
	}

}
